
import request from '@/utils/request'

const api = {
    getProjectList: '/v1/project/page/list', // 获取项目列表
    createProject: '/v1/project/create', // 创建项目
    updateProject: '/v1/project/update', // 修改项目
    changeProjectState: '/v1/project/state/change', // 项目状态切换
    projectDetails: '/v1/project/detail/', // 项目详情
    projectUserList: '/v1/project/user/page/list', // 项目下人员列表
    downloadProjectUser: '/v1/project/user/export', // 导出项目下人员列表
    projectUserUpload: '/v1/project/interview/user/excel/upload', // 项目邀请人员excel上传
    projectUserUploadConfirm: '/v1/project/interview/confirm', // 邀请人员excel确认上传
    projectUserUploadContinue: '/v1/project/interview/continue', // 邀请人员excel继续上传
    removeProjectUser: '/v1/project/user/remove/', // 移除用户
    deleteProject: '/v1/project/delete/', // 删除项目
    getProjectListByCustomer: '/v1/project/list/customer/', // 根据客户获取项目列表
}

// 获取项目列表
export function getProjectList (parameter) {
    return request({
        url: api.getProjectList,
        method: 'get',
        headers: {
            'name':'getProjectList',
        },
        params: parameter
    })
}

// 创建项目
export function createProject (parameter) {
    return request({
        url: api.createProject,
        method: 'post',
        headers: {
            'name':'createProject',
        },
        data: parameter
    })
}
// 修改项目
export function updateProject (parameter) {
    return request({
        url: api.updateProject,
        method: 'post',
        headers: {
            'name':'updateProject',
        },
        data: parameter
    })
}

// 项目状态切换
export function changeProjectState (parameter) {
    return request({
        url: api.changeProjectState,
        method: 'post',
        headers: {
            'name':'changeProjectState',
        },
        data: parameter
    })
}

// 项目详情
export function projectDetails (projectId) {
    return request({
        url: api.projectDetails + projectId,
        method: 'get',
        headers: {
            'name':'projectDetails',
        },
        params: {},
    })
}

// 项目下人员列表
export function projectUserList (parameter) {
    return request({
        url: api.projectUserList,
        method: 'get',
        headers: {
            'name':'projectUserList',
        },
        params: parameter,
    })
}

// 导出项目下人员列表
export function downloadProjectUser (parameter) {
    return request({
        url: api.downloadProjectUser,
        method: 'get',
        responseType: "arraybuffer",
        headers: {
            'name':'downloadProjectUser',
        },
        params: parameter,
    })
}

// 项目邀请人员上传
export function projectUserUpload (parameter){
    return request({
        url: api.projectUserUpload,
        method: 'post',
        headers: {
            'name':'projectUserUpload',
            'file': true,
            'Content-Type': 'multipart/form-data'
        },
        data: parameter,
    })
}

// 邀请人员excel确认上传
export function projectUserUploadConfirm (parameter) {
    return request({
        url: api.projectUserUploadConfirm,
        method: 'post',
        headers: {
            'name':'projectUserUploadConfirm',
        },
        data: parameter
    })
}

// 邀请人员excel继续上传
export function projectUserUploadContinue (parameter) {
    return request({
        url: api.projectUserUploadContinue,
        method: 'post',
        headers: {
            'name':'projectUserUploadContinue',
        },
        data: parameter
    })
}

// 移除用户
export function removeProjectUser (projectUserId) {
    return request({
        url: api.removeProjectUser + projectUserId,
        method: 'post',
        headers: {
            'name':'removeProjectUser',
        },
        data: {}
    })
}

// 删除项目
export function deleteProject (projectId) {
    return request({
        url: api.deleteProject + projectId,
        method: 'post',
        headers: {
            'name':'deleteProject',
        },
        data: {}
    })
}

// 根据客户获取项目列表
export function getProjectListByCustomer (customerId) {
    return request({
        url: api.getProjectListByCustomer + customerId,
        method: 'get',
        headers: {
            'name':'getProjectListByCustomer',
        },
        params: {},
    })
}